﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.ComponentModel.Design;
using ProgNetComponents.Utils;

namespace ProgNetComponents.Design.Editors
{
    /// <summary>
    /// ColumnNameEditor
    /// </summary>
    public class ColumnNameEditor : BaseListEditor
    {
        /// <summary>
        /// Gets a value indicating whether [always refresh items].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [always refresh items]; otherwise, <c>false</c>.
        /// </value>
        protected override bool AlwaysRefreshItems
        {
            get
            {
                return true;
            }
        }
        /// <summary>
        /// Fills the collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="context">The context.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        protected override bool FillCollection(Collections.NamedObjectCollection collection, System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            List<string> columns = DesignUtils.GetColumns(context.Instance, context, provider);
            foreach (string col in columns)
                collection.Add(col, col);
            return true;
        }
    }
}
